<include file="Public:header"/>

<body class="fixed skin-green">
<div class="wrapper">
    <!-- Main Header -->
    <header class="main-header">
        <!-- Header Navbar -->
        <nav class="navbar navbar-static-top" role="navigation"></nav>
    </header>
    <!-- Main sidebar -->
    <include file="Public:menu"/>
    <!-- Content Wrapper -->
    <div class="content-wrapper">
        <section class="content-header">
            <h1> 列表管理</h1>
        </section>
        <section class="content content-ad-list">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <!-- <h3 class="box-title"></h3> -->
                            <div class="select-box">
                                <!-- 新增用户 -->
                                <form action="" method="get" accept-charset="utf-8">
                                    <a class="btn btn-sm btn-primary" href="__URL__/add" role="button">新建新闻</a>
                                    <!-- 搜索 -->
                                    <div class="input-group input-group-sm">
                                        <input type="text" class="form-control" placeholder="请输入关键词">
                                            <span class="input-group-btn">
                                              <button class="btn btn-default iconfont" type="button">&#xe60f;</button>
                                            </span>
                                    </div>
                                    <!-- 类别 -->
                                    <select id="" name="" class="select form-control input-sm">
                                        <option value="4096">全部</option>
                                        <option value="1">已上线</option>
                                        <option value="32">未上线</option>
                                    </select>
                                </form>
                            </div>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <tr>
                                    <th class="ad-id">ID</th>
                                    <th class="ad-title">标题</th>
                                    <th class="ad-brief">简介</th>
                                    <th class="ad-img">图片</th>
                                    <th class="ad-onoff">上线</th>
                                    <th class="ad-control">操作</th>
                                </tr>
                                <volist name="news" id="vo">
                                    <tr>
                                        <td>{$vo.id}</td>
                                        <td>{$vo.title}</td>
                                        <td>{$vo.content}</td>
                                        <td><img src="__PUBLIC__/news_img/{$vo.img}" alt=""></td>
                                        <td><eq name="vo.status" value="1">已上线<else/>未上线</eq></td>
                                        <td>
                                            <a href="__URL__/edit/id/{$vo.id}" class="">修改</a>
                                            <a href="javascript:;" data-toggle="modal" data-target="#deleteConfirmModal" data-url="__URL__/remove/id/{$vo.id}" class="btn-delete">删除</a>
                                        </td>
                                    </tr>
                                </volist>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
            </div>
        </section>
    </div>
    <!-- Main Footer -->
    <footer class="main-footer">
        <!-- To the right -->
        <div class="pull-right hidden-xs">
            Version 1.0
        </div>
        <!-- Default to the left -->
        <strong>Copyright &copy; 2015 <a href="#">viva</a>.</strong> All rights reserved.
    </footer>
</div>
<!-- 模态框 -->
<div class="modal fade" id="deleteConfirmModal" role="dialog" aria-labelledby="deleteConfirmModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Modal title</h4>
      </div> -->
      <div class="modal-body">
        <p>你确定删除该条信息吗？</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary btn-delete">确定</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- REQUIRED JS SCRIPTS -->
<script src="__PUBLIC__/admin/js/jquery-1.11.3.min.js"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/admin/js/common.js"></script>
<script>
    $(function () {
        admin.init();
        //ajax 删除
        $('#deleteConfirmModal').on('show.bs.modal', function(event) {
            var $button = $(event.relatedTarget); // Button that triggered the modal
            var URL = $button.data('url');
            var $item = $button.closest('tr');
            var $modal = $(this);
            var $delete = $modal.find('.btn-delete');

            console.log(URL);
            $delete.on('click', function(event) {
                event.preventDefault();
                $.ajax({
                        url:URL,
                        type: 'get'

                    })
                    .done(function(data) {
                        console.log(data);
                        $item.remove();
                        $modal.modal('hide');

                    })
                    .fail(function() {
                        console.log("error");
                    });
            });

        });
    });
</script>
</body>

</html>
